using OneCaps.Core.Entity;
using OneCaps.Core.Enum;

namespace OneCaps.Core.Interfaces
{
    /// <summary>
    /// 停车记录仓库接口
    /// </summary>
    public interface IParkingRecordRepository : IRepository<ParkingRecord, int>
    {
        /// <summary>
        /// 根据车牌号获取当前停车记录
        /// </summary>
        Task<ParkingRecord?> GetCurrentByLicensePlateAsync(string licensePlate);

        /// <summary>
        /// 根据车牌号获取停车记录历史
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetHistoryByLicensePlateAsync(string licensePlate, DateTime? startDate = null, DateTime? endDate = null);

        /// <summary>
        /// 获取正在停车的记录
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetParkingRecordsAsync();

        /// <summary>
        /// 根据状态获取停车记录
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetByStatusAsync(ParkingRecordStatus status);

        /// <summary>
        /// 根据支付状态获取停车记录
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetByPaymentStatusAsync(PaymentStatus paymentStatus);

        /// <summary>
        /// 根据时间范围获取停车记录
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetByDateRangeAsync(DateTime startDate, DateTime endDate);

        /// <summary>
        /// 根据车辆类型获取停车记录
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetByVehicleTypeAsync(VehicleType vehicleType);

        /// <summary>
        /// 根据车位ID获取停车记录
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetByParkingSpaceIdAsync(int parkingSpaceId);

        /// <summary>
        /// 获取超时停车记录
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetOverdueRecordsAsync(TimeSpan maxDuration);

        /// <summary>
        /// 获取异常停车记录
        /// </summary>
        Task<IEnumerable<ParkingRecord>> GetAbnormalRecordsAsync(DateTime startDate, DateTime endDate);

        /// <summary>
        /// 获取收费统计
        /// </summary>
        Task<ParkingRecordStatistics> GetStatisticsAsync(DateTime startDate, DateTime endDate);

        /// <summary>
        /// 获取今日收费统计
        /// </summary>
        Task<ParkingRecordStatistics> GetTodayStatisticsAsync();

        /// <summary>
        /// 获取本月收费统计
        /// </summary>
        Task<ParkingRecordStatistics> GetMonthStatisticsAsync(int year, int month);
    }

    /// <summary>
    /// 停车记录统计信息
    /// </summary>
    public class ParkingRecordStatistics
    {
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
        public int TotalRecords { get; set; }
        public int CompletedRecords { get; set; }
        public int ParkingRecords { get; set; }
        public decimal TotalRevenue { get; set; }
        public decimal TotalDiscount { get; set; }
        public Dictionary<VehicleType, int> RecordsByVehicleType { get; set; } = new();
        public Dictionary<PaymentMethod, decimal> RevenueByPaymentMethod { get; set; } = new();
        public Dictionary<PaymentStatus, int> RecordsByPaymentStatus { get; set; } = new();
    }
} 